<template>
  <div>
    <table class="moves_list">
      <thead>
        <tr>
          <th>序号</th>
          <th>标题</th>
          <th>内容</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in moves" :key="item.id">
          <td>{{index+1}}</td>
          <td>{{item.title}}</td>
          <td>{{item.content}}</td>
          <td>
            <button @click="xiugai(id)">修改</button>
            <button @click="shanchu(index)">删除</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  props: ["moves"],
  data() {
    return {};
  },
  methods: {
    //修改
    xiugai(id) {
      this.$emit("xiugai", id);
    },
    //删除
    shanchu(index) {
      this.$emit("shanchu", index);
      console.log("准备删除");
    }
  }
};
</script>

<style scoped>
/* 表格 */
.moves_list {
  width: 600px;
  margin: 0 auto;
  border-collapse: collapse;
}
.moves_list tr th,
.moves_list tr td {
  text-align: center;
  border: 1px solid #eee;
  padding: 10px 0;
}
</style>